﻿package Interface.MenuClasses
{	
	import Fonts.FranclinGothicDemi;
	import Core.Page;

	import flash.display.Sprite;
	import flash.text.TextField;	
	import flash.text.TextFormat;	
	import flash.events.MouseEvent;

	public class UpMenuLabel extends Sprite
	{
		private var FText:TextField;
		private var FCover:Sprite;
		private var FPage:Page;
		
		private var FSelectd:Boolean;
		
		public function UpMenuLabel(APage:Page = null):void
		{
			FSelectd = false;
			FPage = APage;
			
			var vFont:FranclinGothicDemi = new FranclinGothicDemi();
			var vFormat:TextFormat = new TextFormat(vFont.fontName);
			vFormat.size = 13;			
			vFormat.align = 'center';			
			
			FText = new TextField();						
			FText.embedFonts = true;
			FText.defaultTextFormat = vFormat;
			FText.selectable = false;			
			FText.text = APage.MenuName;			
			FText.width = FText.textWidth + 10;
			FText.height = FText.textHeight;
			FText.textColor = 0xFFFFFF;
			addChild(FText);
									
			FCover = new Sprite();
			FCover.graphics.beginFill(0xFFFFFF, 0);
			FCover.graphics.drawRect(0, 0, width, height + 10);
			FCover.graphics.endFill();
			FCover.useHandCursor = true;
			FCover.buttonMode = true;
			addChild(FCover);
				
			addEventListener(MouseEvent.MOUSE_OVER, OnMouseOver);
			addEventListener(MouseEvent.MOUSE_OUT, OnMouseOut);		
		}
		
		public function OnMouseOver(e:MouseEvent):void
		{			
			FText.textColor = 0xFFDE00;
		}
		
		public function OnMouseOut(e:MouseEvent):void
		{
			if(!FSelectd)
				FText.textColor = 0xFFFFFF;
		}
		
		public function set Selected(ASelected:Boolean):void
		{
			FSelectd = ASelected;
			if(FSelectd)
				FText.textColor = 0xFFDE00;
			else
				FText.textColor = 0xFFFFFF;
		}
		
		public function get Selected():Boolean
		{
			return FSelectd;
		}
		
		public function get PageLink():Page
		{
			return FPage;
		}
	}	
}
